package com.oscar.ehome.view.pageview;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.text.Editable;
import android.text.InputType;
import android.text.TextWatcher;
import android.text.method.DigitsKeyListener;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.oscar.ehome.R;
import com.oscar.ehome.base.activity.BasesActivity;
import com.oscar.ehome.bean.pagebean.DuDaoXiangQingBean;
import com.oscar.ehome.bean.pagebean.DuDaoZaohuiShuJU;
import com.oscar.ehome.bean.pagebean.InsuranceBean;
import com.oscar.ehome.presenter.PagePresenter;
import com.oscar.ehome.utils.system.SystemConfigFactory;
import com.oscar.ehome.utils.util.CommonUtils;
import com.oscar.ehome.utils.util.SoftKeyBoardListener;
import com.oscar.ehome.utils.util.ToastUtil;
import com.oscar.ehome.utils.view.progressview.ProgressFrameLayout;
import com.oscar.ehome.utils.xrefresh.XRefreshView;
import com.oscar.ehome.utils.xrefresh.XScrollView;
import com.oscar.ehome.view.loginview.LoginActivity;
import com.oscar.ehome.view.pageview.view.DuDaoXiangQingView;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by juxing
 * author: MengWanhe
 * date: On 2017/12/21
 */

public class DuDaoXiangQingActivity extends BasesActivity<DuDaoXiangQingView, PagePresenter> implements DuDaoXiangQingView, XRefreshView.XRefreshViewListener,
        ProgressFrameLayout.AgainRequestListener {


    @BindView(R.id.title_img_back)
    ImageView titleImgBack;
    @BindView(R.id.title_tv_menu)
    TextView titleTvMenu;
    @BindView(R.id.title_layout_left)
    RelativeLayout titleLayoutLeft;
    @BindView(R.id.title_topbar)
    TextView titleTopbar;
    @BindView(R.id.img_spinner)
    ImageView imgSpinner;
    @BindView(R.id.liear_title)
    LinearLayout liearTitle;
    @BindView(R.id.title_tv_right)
    TextView titleTvRight;
    @BindView(R.id.title_img_right)
    ImageView titleImgRight;
    @BindView(R.id.title_img_right_dudao)
    ImageView titleImgRightDuDao;
    @BindView(R.id.home_tv_num)
    TextView homeTvNum;
    @BindView(R.id.title_right_layput)
    RelativeLayout titleRightLayput;
    @BindView(R.id.basetitle_bar)
    RelativeLayout basetitleBar;
    @BindView(R.id.yaoyueqingkuang)
    TextView yaoyueqingkuang;
    @BindView(R.id.daohuilv)
    TextView daohuilv;
    @BindView(R.id.daohuilvbaifenbi)
    TextView daohuilvbaifenbi;
    @BindView(R.id.goupiaozhutiedit)
    EditText goupiaozhutiedit;
    @BindView(R.id.textView2)
    TextView textView2;
    @BindView(R.id.daohuizhuti)
    EditText daohuizhuti;
    @BindView(R.id.daocahngkehu)
    EditText daocahngkehu;
    @BindView(R.id.chengjiaozhuti)
    EditText chengjiaozhuti;
    @BindView(R.id.huomingdanzhuti)
    EditText huomingdanzhuti;
    @BindView(R.id.shuangshouzhuti)
    EditText shuangshouzhuti;
    @BindView(R.id.kehuchengjiaomingxi)
    TextView kehuchengjiaomingxi;
    @BindView(R.id.kehuchengjiaomingxibaifenbi)
    TextView kehuchengjiaomingxibaifenbi;
    @BindView(R.id.chengjiaorenshu)
    EditText chengjiaorenshu;
    @BindView(R.id.danshu)
    EditText danshu;
    @BindView(R.id.baofei)
    EditText baofei;
    @BindView(R.id.textView3)
    TextView textView3;
    @BindView(R.id.zhuanjieshaobaifenbi)
    TextView zhuanjieshaobaifenbi;
    @BindView(R.id.lingjuanrenshu)
    EditText lingjuanrenshu;
    @BindView(R.id.zhuanjieshaorenshu)
    EditText zhuanjieshaorenshu;
    @BindView(R.id.mingdanshu)
    EditText mingdanshu;
    @BindView(R.id.chengjiaozengyuanshu)
    EditText chengjiaozengyuanshu;
    @BindView(R.id.zaoganhuiedit)
    EditText zaoganhuiedit;
    @BindView(R.id.dazaohuiedit)
    EditText dazaohuiedit;
    @BindView(R.id.shidongrenshuedit)
    EditText shidongrenshuedit;
    @BindView(R.id.didubuju)
    LinearLayout didubuju;
    @BindView(R.id.chuangkeshuju)
    LinearLayout chuangkeshuju;
    @BindView(R.id.zaohuishangbao)
    LinearLayout zaohuishangbao;
    @BindView(R.id.sss)
    XScrollView sss;
    @BindView(R.id.shangbaobutton)
    Button shangbaobutton;
    String type;
    PagePresenter presenter;
    String token = "", ticketMain = "0", bodyMain = "0", guestsPresent = "0", transactionMain = "0", mainList = "0", doubleIncomeMainBody = "0", transactionNumber = "0", orderNumber = "0",
            preminu = "0", voucherNumber = "0", referralNumber = "0", increaseNumber = "0",
            listNumber = "0", number1 = "0", number2 = "0", number3 = "0";
    //购票主体  到会主体  到场客户  成交主体  获名单主体  双收主体  成交人数   单数  保费   领券人数   转介绍人数   名数


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dudaoxiangqing);
        ButterKnife.bind(this);
        basetitleBar.setBackgroundColor(Color.parseColor(SystemConfigFactory.getInstance(DuDaoXiangQingActivity.this).getSystemConfig().getColor()));
        initView();
        initData();
    }

    /**
     * 初始化
     */
    public void initView() {
        titleImgBack.setImageResource(R.mipmap.fanhui);
        titleRightLayput.setVisibility(View.VISIBLE);
        titleImgRightDuDao.setImageResource(R.mipmap.biaodantongji);
        titleImgBack.setVisibility(View.VISIBLE);
        titleTopbar.setText("数据上报");
        getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
        Intent in = getIntent();
        type = in.getStringExtra("type");
        if (type.equals("1")) {
            zaohuishangbao.setVisibility(View.VISIBLE);
            chuangkeshuju.setVisibility(View.GONE);
        } else {
            zaohuishangbao.setVisibility(View.GONE);
            chuangkeshuju.setVisibility(View.VISIBLE);
        }
        token = SystemConfigFactory.getInstance(DuDaoXiangQingActivity.this).getSystemConfig().getToken();
        presenter = new PagePresenter(this);
        baofei.setInputType(InputType.TYPE_NUMBER_FLAG_DECIMAL);
        baofei.setKeyListener(new DigitsKeyListener(false, true));

    }


    /**
     * 加载数据
     */
    public void initData() {
        if (isNetWork()) {
            Log.e("232323232", "initData: " + goupiaozhutiedit.getText());
            if (type.equals("1")) {
                //zaohui
                presenter.getdangtianzaohui(token);
            } else {
                presenter.getdangqiandudao(token);
            }
            zaoganhuiedit.addTextChangedListener(new TextWatcher() {
                @Override
                public void beforeTextChanged(CharSequence s, int start, int count, int after) {

                }

                @Override
                public void onTextChanged(CharSequence s, int start, int before, int count) {

                }

                @Override
                public void afterTextChanged(Editable s) {
                    String text = s.toString();
                    int len = s.toString().length();
                    if (len > 1 && text.startsWith("0")) {
                        s.replace(0, 1, "");
                    }

                }
            });
            dazaohuiedit.addTextChangedListener(new TextWatcher() {
                @Override
                public void beforeTextChanged(CharSequence s, int start, int count, int after) {

                }

                @Override
                public void onTextChanged(CharSequence s, int start, int before, int count) {

                }

                @Override
                public void afterTextChanged(Editable s) {
                    String text = s.toString();
                    int len = s.toString().length();
                    if (len > 1 && text.startsWith("0")) {
                        s.replace(0, 1, "");
                    }

                }
            });
            shidongrenshuedit.addTextChangedListener(new TextWatcher() {
                @Override
                public void beforeTextChanged(CharSequence s, int start, int count, int after) {

                }

                @Override
                public void onTextChanged(CharSequence s, int start, int before, int count) {

                }

                @Override
                public void afterTextChanged(Editable s) {
                    String text = s.toString();
                    int len = s.toString().length();
                    if (len > 1 && text.startsWith("0")) {
                        s.replace(0, 1, "");
                    }

                }
            });
            goupiaozhutiedit.addTextChangedListener(new TextWatcher() {
                @Override
                public void beforeTextChanged(CharSequence s, int start, int count, int after) {

                }

                @Override
                public void onTextChanged(CharSequence s, int start, int before, int count) {

                }

                @Override
                public void afterTextChanged(Editable s) {
                    String text = s.toString();
                    int len = s.toString().length();
                    if (len > 1 && text.startsWith("0")) {
                        s.replace(0, 1, "");
                    }

                }
            });
            daohuizhuti.addTextChangedListener(new TextWatcher() {
                @Override
                public void beforeTextChanged(CharSequence s, int start, int count, int after) {

                }

                @Override
                public void onTextChanged(CharSequence s, int start, int before, int count) {

                }

                @Override
                public void afterTextChanged(Editable s) {
                    String text = s.toString();
                    int len = s.toString().length();
                    if (len > 1 && text.startsWith("0")) {
                        s.replace(0, 1, "");
                    }

                }
            });
            daocahngkehu.addTextChangedListener(new TextWatcher() {
                @Override
                public void beforeTextChanged(CharSequence s, int start, int count, int after) {

                }

                @Override
                public void onTextChanged(CharSequence s, int start, int before, int count) {

                }

                @Override
                public void afterTextChanged(Editable s) {
                    String text = s.toString();
                    int len = s.toString().length();
                    if (len > 1 && text.startsWith("0")) {
                        s.replace(0, 1, "");
                    }

                }
            });
            chengjiaozhuti.addTextChangedListener(new TextWatcher() {
                @Override
                public void beforeTextChanged(CharSequence s, int start, int count, int after) {

                }

                @Override
                public void onTextChanged(CharSequence s, int start, int before, int count) {

                }

                @Override
                public void afterTextChanged(Editable s) {
                    String text = s.toString();
                    int len = s.toString().length();
                    if (len > 1 && text.startsWith("0")) {
                        s.replace(0, 1, "");
                    }

                }
            });
            huomingdanzhuti.addTextChangedListener(new TextWatcher() {
                @Override
                public void beforeTextChanged(CharSequence s, int start, int count, int after) {

                }

                @Override
                public void onTextChanged(CharSequence s, int start, int before, int count) {

                }

                @Override
                public void afterTextChanged(Editable s) {
                    String text = s.toString();
                    int len = s.toString().length();
                    if (len > 1 && text.startsWith("0")) {
                        s.replace(0, 1, "");
                    }

                }
            });
            chengjiaorenshu.addTextChangedListener(new TextWatcher() {
                @Override
                public void beforeTextChanged(CharSequence s, int start, int count, int after) {

                }

                @Override
                public void onTextChanged(CharSequence s, int start, int before, int count) {

                }

                @Override
                public void afterTextChanged(Editable s) {
                    String text = s.toString();
                    int len = s.toString().length();
                    if (len > 1 && text.startsWith("0")) {
                        s.replace(0, 1, "");
                    }

                }
            });
            danshu.addTextChangedListener(new TextWatcher() {
                @Override
                public void beforeTextChanged(CharSequence s, int start, int count, int after) {

                }

                @Override
                public void onTextChanged(CharSequence s, int start, int before, int count) {

                }

                @Override
                public void afterTextChanged(Editable s) {
                    String text = s.toString();
                    int len = s.toString().length();
                    if (len > 1 && text.startsWith("0")) {
                        s.replace(0, 1, "");
                    }

                }
            });
            shuangshouzhuti.addTextChangedListener(new TextWatcher() {
                @Override
                public void beforeTextChanged(CharSequence s, int start, int count, int after) {

                }

                @Override
                public void onTextChanged(CharSequence s, int start, int before, int count) {

                }

                @Override
                public void afterTextChanged(Editable s) {
                    String text = s.toString();
                    int len = s.toString().length();
                    if (len > 1 && text.startsWith("0")) {
                        s.replace(0, 1, "");
                    }

                }
            });
            baofei.addTextChangedListener(new TextWatcher() {
                @Override
                public void beforeTextChanged(CharSequence s, int start, int count, int after) {

                }

                @Override
                public void onTextChanged(CharSequence s, int start, int before, int count) {

                }

                @Override
                public void afterTextChanged(Editable s) {
                    String text = s.toString();
                    int len = s.toString().length();
                    if (len > 1 && text.startsWith("0") && !text.equals("0.") && !text.equals("0.0")) {
                        s.replace(0, 1, "");
                    }

                }
            });
            lingjuanrenshu.addTextChangedListener(new TextWatcher() {
                @Override
                public void beforeTextChanged(CharSequence s, int start, int count, int after) {

                }

                @Override
                public void onTextChanged(CharSequence s, int start, int before, int count) {

                }

                @Override
                public void afterTextChanged(Editable s) {
                    String text = s.toString();
                    int len = s.toString().length();
                    if (len > 1 && text.startsWith("0")) {
                        s.replace(0, 1, "");
                    }

                }
            });
            zhuanjieshaorenshu.addTextChangedListener(new TextWatcher() {
                @Override
                public void beforeTextChanged(CharSequence s, int start, int count, int after) {

                }

                @Override
                public void onTextChanged(CharSequence s, int start, int before, int count) {

                }

                @Override
                public void afterTextChanged(Editable s) {
                    String text = s.toString();
                    int len = s.toString().length();
                    if (len > 1 && text.startsWith("0")) {
                        s.replace(0, 1, "");
                    }

                }
            });
            chengjiaozengyuanshu.addTextChangedListener(new TextWatcher() {
                @Override
                public void beforeTextChanged(CharSequence s, int start, int count, int after) {

                }

                @Override
                public void onTextChanged(CharSequence s, int start, int before, int count) {

                }

                @Override
                public void afterTextChanged(Editable s) {
                    String text = s.toString();
                    int len = s.toString().length();
                    if (len > 1 && text.startsWith("0")) {
                        s.replace(0, 1, "");
                    }

                }
            });


            mingdanshu.addTextChangedListener(new TextWatcher() {
                @Override
                public void beforeTextChanged(CharSequence s, int start, int count, int after) {

                }

                @Override
                public void onTextChanged(CharSequence s, int start, int before, int count) {

                }

                @Override
                public void afterTextChanged(Editable s) {
                    String text = s.toString();
                    int len = s.toString().length();
                    if (len > 1 && text.startsWith("0")) {
                        s.replace(0, 1, "");
                    }

                }
            });


            SoftKeyBoardListener.setListener(DuDaoXiangQingActivity.this, new SoftKeyBoardListener.OnSoftKeyBoardChangeListener() {
                @Override
                public void keyBoardShow(int height) {
                    didubuju.setVisibility(View.GONE);
                }

                @Override
                public void keyBoardHide(int height) {
                    didubuju.setVisibility(View.VISIBLE);
                }
            });
            goupiaozhutiedit.setCursorVisible(false);
            daohuizhuti.setCursorVisible(false);
            daocahngkehu.setCursorVisible(false);
            chengjiaozhuti.setCursorVisible(false);
            huomingdanzhuti.setCursorVisible(false);
            chengjiaorenshu.setCursorVisible(false);
            danshu.setCursorVisible(false);
            shuangshouzhuti.setCursorVisible(false);
            baofei.setCursorVisible(false);
            lingjuanrenshu.setCursorVisible(false);
            zhuanjieshaorenshu.setCursorVisible(false);
            mingdanshu.setCursorVisible(false);
            chengjiaozengyuanshu.setCursorVisible(false);
            zaoganhuiedit.setCursorVisible(false);
            dazaohuiedit.setCursorVisible(false);
            shidongrenshuedit.setCursorVisible(false);
            zaoganhuiedit.setOnTouchListener(new View.OnTouchListener() {

                @SuppressLint("ClickableViewAccessibility")
                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    if (MotionEvent.ACTION_DOWN == event.getAction()) {
                        zaoganhuiedit.setCursorVisible(true);// 再次点击显示光标
                    }
                    return false;
                }
            });
            dazaohuiedit.setOnTouchListener(new View.OnTouchListener() {

                @SuppressLint("ClickableViewAccessibility")
                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    if (MotionEvent.ACTION_DOWN == event.getAction()) {
                        dazaohuiedit.setCursorVisible(true);// 再次点击显示光标
                    }
                    return false;
                }
            });
            shidongrenshuedit.setOnTouchListener(new View.OnTouchListener() {

                @SuppressLint("ClickableViewAccessibility")
                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    if (MotionEvent.ACTION_DOWN == event.getAction()) {
                        shidongrenshuedit.setCursorVisible(true);// 再次点击显示光标
                    }
                    return false;
                }
            });
            goupiaozhutiedit.setOnTouchListener(new View.OnTouchListener() {

                @SuppressLint("ClickableViewAccessibility")
                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    if (MotionEvent.ACTION_DOWN == event.getAction()) {
                        goupiaozhutiedit.setCursorVisible(true);// 再次点击显示光标
                    }
                    return false;
                }
            });
            daohuizhuti.setOnTouchListener(new View.OnTouchListener() {

                @SuppressLint("ClickableViewAccessibility")
                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    if (MotionEvent.ACTION_DOWN == event.getAction()) {
                        daohuizhuti.setCursorVisible(true);// 再次点击显示光标
                    }
                    return false;
                }
            });
            daocahngkehu.setOnTouchListener(new View.OnTouchListener() {

                @SuppressLint("ClickableViewAccessibility")
                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    if (MotionEvent.ACTION_DOWN == event.getAction()) {
                        daocahngkehu.setCursorVisible(true);// 再次点击显示光标
                    }
                    return false;
                }
            });
            chengjiaozhuti.setOnTouchListener(new View.OnTouchListener() {

                @SuppressLint("ClickableViewAccessibility")
                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    if (MotionEvent.ACTION_DOWN == event.getAction()) {
                        chengjiaozhuti.setCursorVisible(true);// 再次点击显示光标
                    }
                    return false;
                }
            });
            chengjiaozengyuanshu.setOnTouchListener(new View.OnTouchListener() {

                @SuppressLint("ClickableViewAccessibility")
                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    if (MotionEvent.ACTION_DOWN == event.getAction()) {
                        chengjiaozengyuanshu.setCursorVisible(true);// 再次点击显示光标
                    }
                    return false;
                }
            });
            mingdanshu.setOnTouchListener(new View.OnTouchListener() {

                @SuppressLint("ClickableViewAccessibility")
                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    if (MotionEvent.ACTION_DOWN == event.getAction()) {
                        mingdanshu.setCursorVisible(true);// 再次点击显示光标
                    }
                    return false;
                }
            });
            zhuanjieshaorenshu.setOnTouchListener(new View.OnTouchListener() {

                @SuppressLint("ClickableViewAccessibility")
                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    if (MotionEvent.ACTION_DOWN == event.getAction()) {
                        zhuanjieshaorenshu.setCursorVisible(true);// 再次点击显示光标
                    }
                    return false;
                }
            });
            lingjuanrenshu.setOnTouchListener(new View.OnTouchListener() {

                @SuppressLint("ClickableViewAccessibility")
                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    if (MotionEvent.ACTION_DOWN == event.getAction()) {
                        lingjuanrenshu.setCursorVisible(true);// 再次点击显示光标
                    }
                    return false;
                }
            });
            baofei.setOnTouchListener(new View.OnTouchListener() {

                @SuppressLint("ClickableViewAccessibility")
                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    if (MotionEvent.ACTION_DOWN == event.getAction()) {
                        baofei.setCursorVisible(true);// 再次点击显示光标
                    }
                    return false;
                }
            });
            shuangshouzhuti.setOnTouchListener(new View.OnTouchListener() {

                @SuppressLint("ClickableViewAccessibility")
                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    if (MotionEvent.ACTION_DOWN == event.getAction()) {
                        shuangshouzhuti.setCursorVisible(true);// 再次点击显示光标
                    }
                    return false;
                }
            });
            danshu.setOnTouchListener(new View.OnTouchListener() {

                @SuppressLint("ClickableViewAccessibility")
                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    if (MotionEvent.ACTION_DOWN == event.getAction()) {
                        danshu.setCursorVisible(true);// 再次点击显示光标
                    }
                    return false;
                }
            });
            chengjiaorenshu.setOnTouchListener(new View.OnTouchListener() {

                @SuppressLint("ClickableViewAccessibility")
                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    if (MotionEvent.ACTION_DOWN == event.getAction()) {
                        chengjiaorenshu.setCursorVisible(true);// 再次点击显示光标
                    }
                    return false;
                }
            });
            daohuizhuti.setOnTouchListener(new View.OnTouchListener() {

                @SuppressLint("ClickableViewAccessibility")
                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    if (MotionEvent.ACTION_DOWN == event.getAction()) {
                        daohuizhuti.setCursorVisible(true);// 再次点击显示光标
                    }
                    return false;
                }
            });
            showLoading();
        } else {

        }

    }

    @OnClick({R.id.title_layout_left, R.id.title_img_right, R.id.shangbaobutton})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.title_img_right://返回
                Intent in = new Intent();
                in.setClass(this, DuDaoAtivity.class);
                in.putExtra("type",type);
                startActivity(in);
                break;
            case R.id.title_layout_left://返回
                finish();
                break;
            case R.id.shangbaobutton://返回loge
                Log.e("dianjihou", "onViewClicked: " + "asd");
                //  ticketMain = Double.parseDouble("".equals(goupiaozhutiedit.getText().toString()) ? "0.00" : goupiaozhutiedit.getText().toString());
                ticketMain = goupiaozhutiedit.getText().toString();
                bodyMain = daohuizhuti.getText().toString();
                guestsPresent = daocahngkehu.getText().toString();
                transactionMain = chengjiaozhuti.getText().toString();
                mainList = huomingdanzhuti.getText().toString();
                transactionNumber = chengjiaorenshu.getText().toString();
                orderNumber = danshu.getText().toString();
                doubleIncomeMainBody = shuangshouzhuti.getText().toString();
                preminu = baofei.getText().toString();
                voucherNumber = lingjuanrenshu.getText().toString();
                referralNumber = zhuanjieshaorenshu.getText().toString();


                listNumber = mingdanshu.getText().toString();
                increaseNumber = chengjiaozengyuanshu.getText().toString();
                number1=zaoganhuiedit.getText().toString();
                number2=dazaohuiedit.getText().toString();
                number3=shidongrenshuedit.getText().toString();
                Log.e("dianjihou", "onViewClicked: " + ticketMain + bodyMain + guestsPresent + "    " + transactionMain);

                goupiaozhutiedit.setCursorVisible(false);
                daohuizhuti.setCursorVisible(false);
                daocahngkehu.setCursorVisible(false);
                chengjiaozhuti.setCursorVisible(false);
                huomingdanzhuti.setCursorVisible(false);
                chengjiaorenshu.setCursorVisible(false);
                danshu.setCursorVisible(false);
                shuangshouzhuti.setCursorVisible(false);
                baofei.setCursorVisible(false);
                lingjuanrenshu.setCursorVisible(false);
                zhuanjieshaorenshu.setCursorVisible(false);
                mingdanshu.setCursorVisible(false);
                chengjiaozengyuanshu.setCursorVisible(false);
                zaoganhuiedit.setCursorVisible(false);
                dazaohuiedit.setCursorVisible(false);
                shidongrenshuedit.setCursorVisible(false);
                if(type.equals("1")){
                    presenter.getzaohuishangbao(token,number1,number2,number3);
                }else{
                    presenter.getdudaoxiangqing(token, ticketMain, bodyMain, guestsPresent, transactionMain, mainList, doubleIncomeMainBody, transactionNumber, orderNumber, preminu, voucherNumber, referralNumber,
                            listNumber, increaseNumber);
                }



                break;
        }
    }

    @Override
    public void getdangqiandudao(DuDaoXiangQingBean result) {

        dismissLoading();
        if (result != null && !result.equals("")) {
            shangbaobutton.setText("重 新 上 报");
            if (result.getTicketMain() != 0.0) {
                goupiaozhutiedit.setText((int) result.getTicketMain() + "");

            } else {
                goupiaozhutiedit.setText("0");
            }

            if (result.getBodyMain() != 0.0) {
                daohuizhuti.setText((int) result.getBodyMain() + "");
            } else {
                daohuizhuti.setText("0");
            }
            if (result.getGuestsPresent() != 0.0) {
                daocahngkehu.setText((int) result.getGuestsPresent() + "");
            } else {
                daocahngkehu.setText("0");
            }
            if (result.getTransactionMain() != 0.0) {
                chengjiaozhuti.setText((int) result.getTransactionMain() + "");
            } else {
                chengjiaozhuti.setText("0");
            }
            if (result.getMainList() != 0.0) {
                huomingdanzhuti.setText((int) result.getMainList() + "");
            } else {
                huomingdanzhuti.setText("0");
            }
            if (result.getTransactionNumber() != 0.0) {
                chengjiaorenshu.setText((int) result.getTransactionNumber() + "");
            } else {
                chengjiaorenshu.setText("0");
            }
            if (result.getOrderNumber() != 0.0) {
                danshu.setText((int) result.getOrderNumber() + "");
            } else {
                danshu.setText("0");
            }
            if (result.getDoubleIncomeMainBody() != 0.0) {
                shuangshouzhuti.setText((int) result.getDoubleIncomeMainBody() + "");
            } else {
                shuangshouzhuti.setText("0");
            }
            if (result.getPreminu() != 0.0) {
                baofei.setText(result.getPreminu() + "");
            } else {
                baofei.setText("0.0");
            }
            if (result.getVoucherNumber() != 0.0) {
                lingjuanrenshu.setText((int) result.getVoucherNumber() + "");
            } else {
                lingjuanrenshu.setText("0");
            }
            if (result.getReferralNumber() != 0.0) {
                zhuanjieshaorenshu.setText((int) result.getReferralNumber() + "");
            } else {
                zhuanjieshaorenshu.setText("0");
            }
            if (result.getListNumber() != 0.0) {
                mingdanshu.setText((int) result.getListNumber() + "");
            } else {
                mingdanshu.setText("0");
            }
            if (result.getIncreaseNumber() != 0.0) {
                chengjiaozengyuanshu.setText((int) result.getIncreaseNumber() + "");
            } else {
                chengjiaozengyuanshu.setText("0");
            }
            if (result.getToRate() != null && !result.getToRate().equals("")) {
                daohuilv.setVisibility(View.VISIBLE);
                daohuilvbaifenbi.setVisibility(View.VISIBLE);
                daohuilvbaifenbi.setText(result.getToRate());
            }
            if (result.getTurnoverRate() != null && !result.getTurnoverRate().equals("")) {
                kehuchengjiaomingxibaifenbi.setVisibility(View.VISIBLE);
                kehuchengjiaomingxi.setVisibility(View.VISIBLE);
                kehuchengjiaomingxibaifenbi.setText(result.getTurnoverRate());
            }
            if (result.getReferralRate() != null && !result.getReferralRate().equals("")) {
                zhuanjieshaobaifenbi.setVisibility(View.VISIBLE);
                textView3.setVisibility(View.VISIBLE);
                zhuanjieshaobaifenbi.setText(result.getReferralRate());
            }

        } else {

        }

    }

    @Override
    public void getDuDaoXiangQing(DuDaoXiangQingBean result) {

        goupiaozhutiedit.setText((int) result.getTicketMain() + "");
        shangbaobutton.setText("重 新 上 报");
        daohuizhuti.setText((int) result.getBodyMain() + "");
        daocahngkehu.setText((int) result.getGuestsPresent() + "");
        chengjiaozhuti.setText((int) result.getTransactionMain() + "");
        huomingdanzhuti.setText((int) result.getMainList() + "");
        chengjiaorenshu.setText((int) result.getTransactionNumber() + "");
        danshu.setText((int) result.getOrderNumber() + "");
        shuangshouzhuti.setText((int) result.getDoubleIncomeMainBody() + "");
        baofei.setText(result.getPreminu() + "");
        lingjuanrenshu.setText((int) result.getVoucherNumber() + "");
        zhuanjieshaorenshu.setText((int) result.getReferralNumber() + "");
        mingdanshu.setText((int) result.getListNumber() + "");
        chengjiaozengyuanshu.setText((int) result.getIncreaseNumber() + "");
        if (result.getToRate() != null && !result.getToRate().equals("")) {
            daohuilv.setVisibility(View.VISIBLE);
            daohuilvbaifenbi.setVisibility(View.VISIBLE);
            daohuilvbaifenbi.setText(result.getToRate());
        }
        if (result.getTurnoverRate() != null && !result.getTurnoverRate().equals("")) {
            kehuchengjiaomingxibaifenbi.setVisibility(View.VISIBLE);
            kehuchengjiaomingxi.setVisibility(View.VISIBLE);
            kehuchengjiaomingxibaifenbi.setText(result.getTurnoverRate());
        }
        if (result.getReferralRate() != null && !result.getReferralRate().equals("")) {
            zhuanjieshaobaifenbi.setVisibility(View.VISIBLE);
            textView3.setVisibility(View.VISIBLE);
            zhuanjieshaobaifenbi.setText(result.getReferralRate());
        }

        ToastUtil.show(this, "上报成功");

    }

    @Override
    public void getdangtianzaohui(DuDaoZaohuiShuJU result) {

        dismissLoading();
        if (result != null && !result.equals("")) {
            shangbaobutton.setText("重 新 上 报");
            if (result.getNumber1() != 0) {
                zaoganhuiedit.setText((int) result.getNumber1() + "");

            } else {
                zaoganhuiedit.setText("0");
            }
            if (result.getNumber2() != 0) {
                dazaohuiedit.setText((int) result.getNumber1() + "");

            } else {
                dazaohuiedit.setText("0");
            }
            if (result.getNumber3() != 0) {
                shidongrenshuedit.setText((int) result.getNumber1() + "");

            } else {
                shidongrenshuedit.setText("0");
            }


        } else {

        }

    }

    @Override
    public void getzaohuishuju(DuDaoZaohuiShuJU result) {
        zaoganhuiedit.setText((int) result.getNumber1() + "");
        dazaohuiedit.setText((int) result.getNumber2() + "");
        shidongrenshuedit.setText((int) result.getNumber3() + "");
        ToastUtil.show(this, "上报成功");
    }

    @Override
    public void erroy() {
        dismissLoading();
        ToastUtil.show(this, getString(R.string.erry));
    }

    @Override
    public void erry(String result) {
        dismissLoading();
        if (result.equals("暂无数据")) {

        } else {
            ToastUtil.show(this, result);
        }


        if (result.contains("过期")) {
            getSharedPreferences("appbase", Context.MODE_PRIVATE).edit().clear().commit();
            SystemConfigFactory.getInstance(this).getSystemConfig().SetLogin(false);
            SystemConfigFactory.getInstance(this).getSystemConfig().setIsFirst(true);
            Intent intent = new Intent(this, LoginActivity.class);
            startActivity(intent);
            finish();
        } else {

        }
    }


    @Override
    public void onResume() {
        super.onResume();
        initData();
    }

    @Override
    protected PagePresenter createPresenter() {
        presenter = new PagePresenter(this);
        return presenter;
    }

    /**
     * 判断是否有网
     */
    public boolean isNetWork() {
        boolean netWork = true;
        if (!CommonUtils.isNetConn(this)) {
            netWork = false;
            return netWork;
        }
        return netWork;
    }

    @Override
    public void againRequest() {
//        if (isNetWork()) {
//            initData();
//        } else {
//            ToastUtil.show(this, R.string.pull_to_refresh_network_error);
//        }
    }

    @Override
    public void onRefresh() {

    }

    @Override
    public void onRefresh(boolean isPullDown) {

    }

    @Override
    public void onLoadMore(boolean isSilence) {

    }

    @Override
    public void onRelease(float direction) {

    }

    @Override
    public void onHeaderMove(double headerMovePercent, int offsetY) {

    }
}
